
<template>
  <el-form ref="ruleForm"
           label-width="90px">
    <el-row :gutter="20"
            class="row-sty">
      <el-col :span="12">公司名称：{{record.childTenantName}}</el-col>
      <el-col :span="12">企业ID：{{record.childTenantCode}}</el-col>
    </el-row>
    <el-row :gutter="20"
            class="row-sty">
      <el-col :span="12">联系电话：{{record.childContactMobile}}</el-col>
      <el-col :span="12">状态：{{record.statusName}}</el-col>
    </el-row>
    <el-row :gutter="20"
            class="row-sty">
      <el-col :span="12">申请时间：{{record.createAt}}</el-col>
      <el-col :span="12">审核时间：--</el-col>
    </el-row>
    <el-row :gutter="20"
            class="row-sty">
      <el-col :span="24">申请说明：{{record.applyDesc}}</el-col>
    </el-row>
    <el-form-item prop="reason"
                  class="item-width"
                  label="拒绝原因">
      <nr-select v-model="reason"
                 :options="refuseCause"
                 :props="{ label: 'label', value: 'value' }"
                 :placeholder="placeholder" />
    </el-form-item>
    <div class="footer_buts">
      <el-button type="default"
                 @click="handleReject">拒绝</el-button>
      <el-button type="primary"
                 @click="handleSubmit">通过</el-button>
    </div>
  </el-form>
</template>

<script>
import nrSelect from "@/components/nr/select/Index";
import baseMixin from "@components/mount/mixins/common";
import axios from 'axios'
export default {
  name: "BigDataApproveSubmit",
  components: { nrSelect },
  mixins: [baseMixin],
  props: {
    record: Object,
    placeholder: {
      type: String,
      default () {
        return "请选择拒绝原因";
      }
    },
  },
  data () {
    return {
      refuseCause: [
        { label: "不是本公司的子公司", value: "不是本公司的子公司" },
        { label: "其他原因", value: "其他原因" }
      ],
      reason: null
    };
  },
  methods: {
    async handleReject () {
      if (!this.reason) {
        return this.$message({ type: 'error', message: this.placeholder })
      }
      await axios({
        method: "put",
        url: '/tenant/group/reject',
        data: {
          groupRelationId: this.record.groupRelationId,
          rejectReason: this.reason
        },
      });
      this.reason = null;
      this.$message({ type: "success", message: "操作成功！" });
      this.$emit("confirm");
      this.$emit("cancel");
    },
    async handleSubmit () {
      await axios({
        method: "put",
        url: '/tenant/group/agree',
        data: {
          groupRelationId: this.record.groupRelationId
        },
      });
      this.reason = null;
      this.$message({ type: "success", message: "操作成功！" });
      this.$emit("confirm");
      this.$emit("cancel");
    }
  }
};
</script>
<style lang="scss" scoped>
.row-sty {
  margin: 20px 10px 20px 10px !important;
}
.footer_buts {
  padding-top: 12px;
  display: flex;
  justify-content: flex-end;
}
</style>
